package com.bwie.controller;

import com.bwie.service.TbOrderService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.TbProdVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/3/21 14:16
 */

@RestController
@RequestMapping("/order/index")
public class IndexController {

    @Autowired
    TbOrderService tbOrderService;

    /**
     * @description 根据ID获取订单信息
     * @params [orderId]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/3/21 14:17
     */
    @PostMapping("/getOrderById/{orderId}")
    public R getOrderById(@PathVariable("orderId") Integer orderId) {
        return tbOrderService.getOrderById(orderId);
    }

    /**
     * @description 分页获取订单
     * @params []
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/3/22 9:26
     */
    @PostMapping("/getOrderList")
    public R getOrderList(@RequestBody PageInfoVo pageInfoVo) {
        return tbOrderService.getOrderList(pageInfoVo);
    }

    /**
     * @description 下单
     * @params [prodVoList]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/3 10:07
     */
    @PostMapping("/addOrder")
    public R addOrder(@RequestBody List<TbProdVo> prodVoList) {
        return tbOrderService.addOrder(prodVoList);
    }

}
